Vpa.System = {
    rootPath : v8System("pwd").trim(),
    loadProgress : function(fileArr){
        var rootPath = Vpa.System.rootPath,
            fReg = /\.js$/;
        for(var i=0, len=fileArr.length;i<len;i++){
            var fName = fileArr[i];
            if(fReg.test(fName)){
                v8ImportJs(rootPath + "/" + fName);
            }
            else{
                Vpa.System.loadProgress(Vpa.System.getAllFiles(fName));
            }
        }
    },
    preprocess : function(){
        v8System("rm -rf _infiles;mkdir _infiles;cd _infiles;svn co "+vpaConfig.svnPath);
        return this.getAllFiles("_infiles/"+vpaConfig.folders);
    },
    getAllFiles : function(path){
        var output = v8System("ls -lR "+path);
        
        var folders = output.split("\n\n");
        
        var fList = [];
        for(var i = 0, fLen = folders.length;i<fLen;i++){
            var lines = folders[i].split('\n');
            if(lines.length == 1){
                var strs = lines[0].divideByWhite(8);
                if(!(/^[d\-wrx]{10}$/.test(strs[0])) || strs.length<8)
                    continue;
                fList[strs[7]] = {
                    isFolder : false
                };
            }else{
                if(lines[0].charAt(lines[0].length-1) != ":" || lines.length<3)
                    continue;
                
                var pnode = fList[lines[0].substring(0,lines[0].length-1)] = {
                    isFolder : true,
                    children : []
                }
                
               var dir = lines[0].substring(0,lines[0].length-1)+"/";
                for(var j=2,len=lines.length;j<len;j++){
                    var strs = lines[j].divideByWhite(8);
                    if(strs.length<8)
                        continue;
                    if('-' == strs[0].charAt(0)){
                        pnode.children.push(strs[7]);
                    }
                }
            }
            
        }
        return fList;
    }
}
